# Maintainer: Philipp Smirnov https://github.com/sad-poet

_realname=gnatformat
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=25.0.0
pkgrel=2
pkgdesc="An opinionated code formatter for the Ada language. (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64')
url="https://github.com/AdaCore/gnatformat"
license=("spdx:Apache-2.0 WITH LLVM-exception")
depends=(
  "${MINGW_PACKAGE_PREFIX}-gcc-ada"
  "${MINGW_PACKAGE_PREFIX}-gcc-libs"
  "${MINGW_PACKAGE_PREFIX}-gnatcoll-core"
  "${MINGW_PACKAGE_PREFIX}-gnatcoll-gmp"
  "${MINGW_PACKAGE_PREFIX}-gnatcoll-iconv"
  "${MINGW_PACKAGE_PREFIX}-langkit_support"
  "${MINGW_PACKAGE_PREFIX}-libadalang"
  "${MINGW_PACKAGE_PREFIX}-libgpr"
  "${MINGW_PACKAGE_PREFIX}-libvss"
  "${MINGW_PACKAGE_PREFIX}-prettier-ada"
  "${MINGW_PACKAGE_PREFIX}-xmlada"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-gprbuild"
)
source=("https://github.com/AdaCore/gnatformat/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('722e0881a0954fb0cc948a7f9028a97a6f744373db400976fbf638d41af50a51')

build() {
  [[ -d "${srcdir}"/build-${MSYSTEM} ]] && rm -rf "${srcdir}"/build-${MSYSTEM}
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}"/build-${MSYSTEM}
  cd "${srcdir}"/build-${MSYSTEM}

  BUILD_MODE=prod \
  LIBRARY_TYPE=relocatable \
  make lib bin
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}

  BUILD_MODE=prod \
  LIBRARY_TYPE=relocatable \
  make install PREFIX=${pkgdir}${MINGW_PREFIX}

  install -Dm644 -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}" \
    "${srcdir}/${_realname}-${pkgver}/LICENSE.txt"
}
